import time


def read2list(filename):
    file = open(filename, 'r')
    data = file.readlines()
    return data


m1 = read2list("m1_sorted.txt")
m2 = read2list("m2_reverse.txt")
m3 = read2list("m3_shuffle.txt")

a, a1 = [m1, m2, m3], ["m1_sorted", "m2_reverse", "m3_shuffle"]

for k in range(len(a)):
    t_start = time.time()
    for i in range(len(a[k]) - 1):
        for j in range(len(a[k]) - i - 1):
            if a[k][j] > a[k][j + 1]:
                a[k][j], a[k][j + 1] = a[k][j + 1], a[k][j]
    t_finish = time.time()
    print(a1[k], round((t_finish - t_start) * 1000), "milliseconds")
